Radar Plots
An R tutorial on how to create radar plots
Data
# devtools::install_github("derekmichaelwright/agData")
library(agData)
# devtools::install_github("ricardo-bion/ggradar")
library(ggradar)Prepare Data
# Prep data
myLocs <- c("Rosthern, Canada", "Sutherland, Canada",
"Bhopal, India", "Jessore, Bangladesh", "Bardiya, Nepal",
"Marchouch, Morocco", "Cordoba, Spain", "Metaponto, Italy" )
dd <- read.csv("data_radar_plots.csv") %>%
mutate(Location = factor(Location, levels = myLocs))DTF by Genotypes
# Prep data
myNames <- c("PI 320953 LSP AGL", "Indianhead AGL", "PI 339285 AGL",
"IG 4258 AGL", "CN 105791 AGL", "ILL 5888 AGL")
xx <- dd %>%
group_by(Location) %>%
mutate(DTF = scales::rescale(DTF)) %>%
spread(Location, DTF) %>%
filter(Name %in% myNames) %>%
mutate(Name = factor(Name, levels = myNames))
DT::datatable(xx)# Plot
myTitle <- "Reltaive days to flower for selected lentil accessions\nfrom a lentil diversity panel accross environments"
mp <- ggradar(xx, plot.title = myTitle, legend.position = "bottom")
ggsave("radar_plots_01.png", mp, width = 11, height = 10)# Prep data
xx <- read.csv("data_radar_plots.csv") %>%
group_by(Location) %>%
mutate(DTF = scales::rescale(DTF)) %>%
spread(Location, DTF) %>%
mutate_at(vars(-Name), scales::rescale)
# PDF
pdf("radar_plots.pdf", width = 11, height = 10)
for(i in unique(xx$Name)) {
xi <- xx %>% filter(Name == i)
mp <- ggradar(xi)
print(mp, plot.title = i)
}
dev.off()© Derek Michael Wright